package hadoop.topN.question2;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Partitioner;

public class CoursePartitioner2 extends Partitioner<StuBean, NullWritable> {
    //根据不同课程名称分区
    @Override
    public int getPartition(StuBean stuBean, NullWritable nullWritable, int i) {
        if (stuBean.getCourseName().equals("math")) {
            return 0;
        } else if (stuBean.getCourseName().equals("computer")) {
            return 1;
        } else if (stuBean.getCourseName().equals("english")) {
            return 2;
        } else {
            return 3;
        }
    }
}
